package com.cacshanghai.cac_oa_client.ui;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.TextView;

import com.cacshanghai.cac_oa_client.R;

public class LoginActivity extends BaseActivity {

    private TextView tv_login;
    private AlertDialog dialog;
    private Handler handler = new Handler();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

//        startActivity(new Intent(LoginActivity.this, MainActivity.class));

        initLoadingDialog();

        tv_login = (TextView) findViewById(R.id.tv_login);
        tv_login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.show();
                handler.postDelayed(
                        new Runnable() {
                            @Override
                            public void run() {
                                dialog.dismiss();
                                Intent intent = new Intent(LoginActivity.this, MainActivity.class);
                                startActivity(intent);
                            }
                        }, 1500
                );
            }
        });
    }

    private void initLoadingDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
        dialog = builder.setView(R.layout.dialog_loading).setCancelable(false).create();
    }
}
